<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
//节点和节点之间的关系.
//获取dom树
var dom = window.document;
//获取指定id 的标签节点.
function test() {
	var form = dom.getElementById("form1");
	//获取父节点.
	//alert(form.parentNode.nodeName);
	// 获取子节点(Node 包含 文本,注释,标签)
	var childArr = form.childNodes;
	//alert(childArr.length);
	/*
	for (var i = 0; i < childArr.length; i++) {
	alert(childArr[i]);
	}
	*/
	// 获取第一个孩子.
	var first = form.firstChild;
	//alert(first);
	//最后一个孩子.
	var last = form.lastChild;
	//alert(last);
	// 获取下兄弟(获取弟弟)
	var sibling = form.nextSibling;
	//alert(sibling.nodeName);
	// 获取大哥
	var previous = form.previousSibling;
	alert(previous.nodeName);
}
test();
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>javascript</title>
</head>
<body onmousemove="test(this)">
		<a>哈哈</a>
		<form id="form1">
			<label>姓名:</label>
			<input type="text" />
		</form>
</body>
</html>